<?php
require_once('../db/check_login.php');
require_once('../db/config.php');
$db=new db($config);
$getAttrId=$_GET['getAttrId'];
$getCommenter=$_GET['getCommenter'];
$getReplyTo=$_GET['getReplyTo'];
$getReplyContent=$_GET['getReplyContent'];
$arr=explode('_',$getAttrId);//数组里面的0个代表评论id

$data=array(
'commentId'=>$arr[0],
'replyerFrom'=>$getCommenter,
'replyerto'=>$getReplyTo,
'content'=>$getReplyContent,
'reply_time'=>date('Y-m-d H:i:s')
);
$insertId=$db->insert('commentreply',$data);
if($insertId>0){
$insertData=$db->foundbyId('commentreply',$insertId);
$userData=$db->foundOnebyWhere('user',"user='$getCommenter'");//找到评论者的头像
$replyData="<div class='replyBox'><div class='boxUserImg'><img src='".$userData['userImg']."' width='45px' height='45px'/></div><div class='boxUser'><span class='userName'>".$getCommenter."</span>回复<span class='userName'>".$getReplyTo."</span></div><div class='boxContent'>".$getReplyContent."</div><div class='boxBottom' attr-id='".$arr[0]."_".$insertId."'>".$insertData['reply_time']."<span class='reply' attr-show='off' attr-id='".$arr[0]."_".$insertId."' attr-user='".$getCommenter."'><a href='javascript:;'>回复</a></span><span class='praiseNum' praise-id='".$arr[0]."_".$insertId."'>(0)</span><span class='praise' attr-praiseId='".$arr[0]."_".$insertId."'><a href='javascript:;'>赞</a></span></div></div>";
	echo json_encode(array('errorCode'=>0,'commentId'=>$arr[0],'replyData'=>$replyData,'msg'=>'回复成功'));
}else{
	echo json_encode(array('errorCode'=>1,'msg'=>'评论失败'));	
}

?>